package com.liuzy.beauty;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * http://www.mm131.com/
 * 
 * @author liuzy
 * @since 2015年10月26日
 */
public class MM131 extends Beauty {
	public static void main(String[] args) {
		new MM131("D:\\beauty\\mm131\\", "http://www.mm131.com/").start();
	}

	public MM131(String saveDir, String startUrl) {
		super(saveDir, startUrl);
	}

	@Override
	public void search(String url, String html) {
		Matcher matcher = Pattern.compile("href=([\"]{0,1}|[']{0,1})(http://.*?.html)", Pattern.CASE_INSENSITIVE).matcher(html);
		while (matcher.find()) {
			grilQueue.add(matcher.group(2));
		}
		matcher = Pattern.compile("href=(\"|')?(\\d+_\\d+.html)(\"|')?", Pattern.CASE_INSENSITIVE).matcher(html);
		while (matcher.find()) {
			grilQueue.add(url.substring(0, url.lastIndexOf("/") + 1) + matcher.group(2));
		}
		matcher = Pattern.compile("http://img.*?.jpg").matcher(html);
		while (matcher.find()) {
			imageQueue.add(matcher.group());
		}
	}

	@Override
	public String reName(String url) {
		return url.substring(url.indexOf("pic/") + 4).replaceAll("/", ".");
	}

}
